package com.springcloud.sc.ucpv5.client.commondata.data;

import com.springcloud.sc.ucpv5.client.commondata.datachange.DataExChange;
import com.google.protobuf.Message;

/**
 * Generated from IDL struct "SSInfoType".
 *
 * @author JacORB IDL compiler V 2.3-beta-2, 14-Oct-2006
 * @version generated at 2014-10-29 11:48:54
 */

public final class SSInfoType extends DataExChange {
    public SSInfoType() {
    }

    public int type;
    public int open;
    public com.springcloud.sc.ucpv5.client.commondata.data.SSInfoPara[] SSInfoParaList;

    public SSInfoType(int type, int open, com.springcloud.sc.ucpv5.client.commondata.data.SSInfoPara[] SSInfoParaList) {
	this.type = type;
	this.open = open;
	this.SSInfoParaList = SSInfoParaList;
    }

    public Message dataChangeCommonToProBufData() {
	try {
	    com.proto.uuos_sdk_pb.SSInfoType.Builder builder_dst = com.proto.uuos_sdk_pb.SSInfoType.newBuilder();
	    builder_dst.setType(type);
	    builder_dst.setOpen(open);

	    for (SSInfoPara sSInfoPara : SSInfoParaList) {
		builder_dst.addSSInfoParaList((com.proto.uuos_sdk_pb.SSInfoPara) sSInfoPara.dataChangeCommonToProBufData());
	    }

	    Message pbMessage = builder_dst.build();
	    return pbMessage;
	} catch (Exception e) {
	    // TODO: handle exception
	}

	return null;
    }

    /**
     * 从probuf对象获取当前对象
     * 
     * @param builder_src
     * @return
     */
    public void dataChangeProBufDataToCommon(Message builder_src) {
	try {
	    com.proto.uuos_sdk_pb.SSInfoType userInfo = (com.proto.uuos_sdk_pb.SSInfoType) builder_src;

	    type = userInfo.getType();
	    open = userInfo.getOpen();
	    SSInfoParaList = new com.springcloud.sc.ucpv5.client.commondata.data.SSInfoPara[userInfo.getSSInfoParaListCount()];
	    for (int i = 0; i < userInfo.getSSInfoParaListCount(); i++) {
		SSInfoParaList[i] = new com.springcloud.sc.ucpv5.client.commondata.data.SSInfoPara();
		SSInfoParaList[i].dataChangeProBufDataToCommon(userInfo.getSSInfoParaList(i));
	    }
	} catch (Exception e) {
	    e.printStackTrace();
	}
    }
}
